//
//  JXTabBarController.swift
//  weibo-new
//
//  Created by mac on 2017/3/27.
//  Copyright © 2017年 gjx. All rights reserved.
//

import UIKit

class JXTabBarController: UITabBarController {
    lazy var composeBtn: UIButton = UIButton(imgName: "tabbar_compose_icon_add", backImgName: "tabbar_compose_button")

    override func viewDidLoad() {
        super.viewDidLoad()

        setupComposeBtn()
    }



}


// MARK:-- UI相关
extension JXTabBarController {
    func setupComposeBtn()  {
        tabBar.tintColor = UIColor.orange
        
        // 添加发布按钮
        tabBar.addSubview(composeBtn)
        composeBtn.center = CGPoint(x: tabBar.center.x, y: tabBar.bounds.size.height*0.5)
        
        // 监听事件点击
        composeBtn.addTarget(self, action: #selector(composeBtnClicked), for: .touchUpInside)
    }
}

// MARK:-- 事件监听
extension JXTabBarController {
    @objc fileprivate func composeBtnClicked() {
        let composeVC = ComposeViewController()
        let nav = JXNavigationViewController(rootViewController: composeVC)
        present(nav, animated: true, completion: nil)
    }
}
